<?php
  include_once('../conn.php');

  $id = $_POST['id'];
  $book_name = $_POST['book_name'];
  $book_category = $_POST['book_category'];
  $book_position = $_POST['book_position'];
  $book_count = $_POST['book_count'];
  if(strlen($book_name) < 1) {
    alert('图书名称不能小于1位', 'book_list.php');
    exit();
  }

  $sql = "update book set 
    book_name = '$book_name', 
    book_category = '$book_category',
    book_position = '$book_position',
    book_count = '$book_count'
    where id = $id
    ";
  // echo $sql;
  $result = mysqli_query($conn, $sql);
  if($result) {
    alert('图书修改成功', 'book_list.php');
  } else {
    alert('图书修改失败', 'book_list.php');
  }

  mysqli_close($conn);
?>